﻿using System.Collections.Generic;
using System.Linq;
using UnityEngine;


namespace RStudio.Elevator
{
    /// <summary>
    /// 模块|呼叫器
    /// </summary>
    public class ElevatorModuleCall
    {
        public ElevatorModuleCall()
        {
            this.QueueList = new HashSet<ElevatorQueue>();
        }

        public HashSet<ElevatorQueue> QueueList { get; private set; }


        /// <summary>
        /// 注册|队列组
        /// </summary>
        public void Register(ElevatorQueue queue)
        { 
            this.QueueList.Add(queue);

            Debug.Log($"<b>[ElevatorModuleCall]</b> {queue.Component.Key} 注册了全局控制器");
        }

        /// <summary>
        /// 获取|队列组
        /// </summary>
        public ElevatorQueue Get(string name)
        {
            var match = this.QueueList.ToList().Find(e => e.Component.Key == name);

            if (match == null)
            { 
                return null;
            }

            return match;
        }
    }
}
